import { http } from '@/apis/http';
import type { ApiResponse } from '@/apis/types/Response';
import type { Login, LoginVo, User } from '@/apis/types/User';

export const userApi = {
    /**
     * 登录
     */
    login(data: Login) {
        return http.post<ApiResponse<LoginVo>>('/user/login', data);
    },
    /**
     * 注册
     */
    register(user: User) {
        return http.post<ApiResponse<null>>('/user/register', user);
    },
    /**
     * 退出登录
     */
    logout(userId: number) {
        return http.post<ApiResponse<null>>('/user/logout', { id: userId });
    },
    /**
     * 更新用户信息 
     */
    updateInfo(user: User) {
        return http.post<ApiResponse<null>>('/user/updateInfo', user);
    },
    /**
     * 获取admin信息
     */
    getAdminInfo() {
        return http.get<ApiResponse<User>>('/user/adminInfo');
    }
}   